program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  n, i, min, max, j: integer;
  fin: textfile;
begin
  assignfile(fin, 'input.txt');
  reset(fin);
  readln(fin, n);
  read(fin, min);
  max:=min;
  for i:= 0 to n-2 do
  begin
    read(fin, j);
    if (j<min) then
      min:=j;
    if (j> max) then
      max:=j;
  end;
  writeln(min+max);
  closefile(fin);
  readln;
end.
 